## Setting Environment Variables

### In the VSCode Playground

Once you open a `.baml` file in VSCode, you should see a small button over every BAML function: `Open Playground`. Then you should be able to set environment variables in the settings tab.

<img src="/assets/vscode/code-lens.png" alt="VSCode Code Lens" />

Or type `BAML Playground` in the VSCode Command Bar (`CMD + Shift + P` or `CTRL + Shift + P`) to open the playground.

### For Boundary Studio Integration

To send logs and traces to Boundary Studio, you need to set the `BOUNDARY_API_KEY` environment variable. This key is provided when you create an API key in your Boundary Studio dashboard.

<Tabs>
  <Tab title="Next.js" language="typescript">
    ```bash
    # .env.local
    BOUNDARY_API_KEY=your_api_key_here
    ```
  </Tab>
  <Tab title="Express.js" language="typescript">
    ```bash
    # .env
    BOUNDARY_API_KEY=your_api_key_here
    ```
  </Tab>
  <Tab title="Flask" language="python">
    ```bash
    # .env
    BOUNDARY_API_KEY=your_api_key_here
    ```
  </Tab>
  <Tab title="Rails" language="ruby">
    ```yaml
    # config/application.yml
    BOUNDARY_API_KEY: your_api_key_here
    ```
  </Tab>
</Tabs>

### For Your App (Default)

BAML will do its best to load environment variables from your program. Any of the following strategies for setting env vars are compatible with BAML:

- Setting them in your shell before running your program
- In your `Dockerfile`
- In your `next.config.js`
- In your Kubernetes manifest
- From `secrets-store.csi.k8s.io`
- From a secrets provider such as [Infisical](https://infisical.com/) / [Doppler](https://www.doppler.com/)
- From a `.env` file (using `dotenv` CLI)
- Using account credentials for ephemeral token generation (e.g., Vertex AI Auth Tokens)
- `python-dotenv` package in Python or `dotenv` package in Node.js

```bash
export MY_SUPER_SECRET_API_KEY="..."
python my_program_using_baml.py
```

<Tabs>
  <Tab title="python" language="python">

    ```python
    from dotenv import load_dotenv
    from baml_client import b

    load_dotenv()
    ```
  </Tab>
  <Tab title="typescript" language="typescript">

    ```typescript
    import dotenv from 'dotenv'
    import { b } from './baml_client'

    dotenv.config()
    ```
  </Tab>
  <Tab title="ruby" language="ruby">
    ```ruby
    require 'dotenv/load'
    require 'baml_client'
    ```
  </Tab>
</Tabs>
